package com.ujs.controller;

import com.ujs.pojo.Authority;
import com.ujs.service.AuthorityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

/**
 * @title: AuthorityController
 * @Author liyunxiao
 * @Date: 2021/1/14 1:08
 */
@Controller
@RequestMapping("/authority")
public class AuthorityController {
    @Autowired
    private AuthorityService authorityService;

    @RequestMapping("/findAll")
    public String findAll(Model model){
        List<Authority> authorityList = authorityService.findAll();
        model.addAttribute("authorityList",authorityList);
        return "authority-list";
    }

    @RequestMapping("/authority-add")
    public String authorityAdd(){
        return "authority-add";
    }
    @RequestMapping("/save")
    public String save(Authority authority){
        authorityService.save(authority);
        return "redirect:findAll";
    }
}
